<?php

class subject_volume_model extends CI_Model 
{
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }

	// Get Access ID(s) based on Subject ID
	function getAccessIDsForSubject( $subject_id )
	{
		// Select only author_id in result set
		$this->db->select('access_id');
		$this->db->where('subject_id', $subject_id);
		$this->db->from('tbl_subject_volume');
		$result = $this->db->get()->result();
		
		// Convert result to array and return them
		$ret_array = array();
		foreach ($result as $key=>$value)
			array_push($ret_array, $value->access_id);
		return $ret_array;
	}
	
	// Get Author ID(s) based on Access ID
	function getSubjectIDsForVolume( $access_id )
	{
		// Select only author_id in result set
		$this->db->select('subject_id');
		$this->db->where('access_id', $access_id);
		$this->db->from('tbl_subject_volume');
		$result = $this->db->get()->result();
		
		// Convert result to array and return them
		$ret_array = array();
		foreach ($result as $key=>$value)
			array_push($ret_array, $value->subject_id);
		return $ret_array;
	}
	
	// Remove an entry from table tbl_subject_volume
	public function remove($subject_id, $access_id)
	{
		$delete_where_array = array('subject_id' => $subject_id,
									'access_id' => $access_id );
	
		$this->db->delete('tbl_subject_volume', $delete_where_array);
	}
	
	// Add an entry to table tbl_subject_volume
	public function add($subject_id, $access_id)
	{
		$data_array = array('subject_id' => $subject_id,
							'access_id' => $access_id );
							
		$this->db->insert('tbl_subject_volume', $data_array);
	}
}

?>